/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Francisco
 */
@Entity
@Table(name = "operar_consumo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OperarConsumo.findAll", query = "SELECT o FROM OperarConsumo o"),
    @NamedQuery(name = "OperarConsumo.findByIdOperarConsumo", query = "SELECT o FROM OperarConsumo o WHERE o.idOperarConsumo = :idOperarConsumo"),
    @NamedQuery(name = "OperarConsumo.findByDescripcion", query = "SELECT o FROM OperarConsumo o WHERE o.descripcion = :descripcion"),
    @NamedQuery(name = "OperarConsumo.findByFechaConsumo", query = "SELECT o FROM OperarConsumo o WHERE o.fechaConsumo = :fechaConsumo")})
public class OperarConsumo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_operar_consumo")
    private Integer idOperarConsumo;
    @Size(max = 200)
    @Column(name = "descripcion")
    private String descripcion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha_consumo")
    @Temporal(TemporalType.DATE)
    private Date fechaConsumo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOperarConsumo")
    private List<OperarConsumoIngreso> operarConsumoIngresoList;
    @JoinColumn(name = "id_usuario", referencedColumnName = "id_usuario")
    @ManyToOne(optional = false)
    private Usuario idUsuario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOperarConsumo")
    private List<OperarConsumoConsumible> operarConsumoConsumibleList;

    public OperarConsumo() {
    }

    public OperarConsumo(Integer idOperarConsumo) {
        this.idOperarConsumo = idOperarConsumo;
    }

    public OperarConsumo(Integer idOperarConsumo, Date fechaConsumo) {
        this.idOperarConsumo = idOperarConsumo;
        this.fechaConsumo = fechaConsumo;
    }

    public Integer getIdOperarConsumo() {
        return idOperarConsumo;
    }

    public void setIdOperarConsumo(Integer idOperarConsumo) {
        this.idOperarConsumo = idOperarConsumo;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Date getFechaConsumo() {
        return fechaConsumo;
    }

    public void setFechaConsumo(Date fechaConsumo) {
        this.fechaConsumo = fechaConsumo;
    }

    @XmlTransient
    public List<OperarConsumoIngreso> getOperarConsumoIngresoList() {
        return operarConsumoIngresoList;
    }

    public void setOperarConsumoIngresoList(List<OperarConsumoIngreso> operarConsumoIngresoList) {
        this.operarConsumoIngresoList = operarConsumoIngresoList;
    }

    public Usuario getIdUsuario() {
        return idUsuario;
    }

    public void setIdUsuario(Usuario idUsuario) {
        this.idUsuario = idUsuario;
    }

    @XmlTransient
    public List<OperarConsumoConsumible> getOperarConsumoConsumibleList() {
        return operarConsumoConsumibleList;
    }

    public void setOperarConsumoConsumibleList(List<OperarConsumoConsumible> operarConsumoConsumibleList) {
        this.operarConsumoConsumibleList = operarConsumoConsumibleList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOperarConsumo != null ? idOperarConsumo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OperarConsumo)) {
            return false;
        }
        OperarConsumo other = (OperarConsumo) object;
        if ((this.idOperarConsumo == null && other.idOperarConsumo != null) || (this.idOperarConsumo != null && !this.idOperarConsumo.equals(other.idOperarConsumo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.OperarConsumo[ idOperarConsumo=" + idOperarConsumo + " ]";
    }
    
}
